//
//  XMGPushGuideView.m
//  百思不得姐
//
//  Created by 杨庆 on 2017/1/6.
//  Copyright © 2017年 杨庆. All rights reserved.
//

#import "XMGPushGuideView.h"

@implementation XMGPushGuideView
+(instancetype)guideView{
	return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject] ;
}

- (IBAction)close:(id)sender {
	[self removeFromSuperview];
}


+(void)show{
	
	UIWindow *window=[UIApplication sharedApplication].keyWindow;
	//取出当前版本
	NSString*currentVersion=[NSBundle mainBundle ].infoDictionary[@"CFBundleShortVersionString"];
//	NSLog(@"%@",currentVersion);
	//取出沙盒版本
	NSString*versionKey=@"CFBundleShortVersionString";
	NSString*sandBoxVersion=[[NSUserDefaults standardUserDefaults]stringForKey:versionKey];
//	NSLog(@"%@",sandBoxVersion);
	//版本如同,显示指导界面
	if (![currentVersion isEqualToString:sandBoxVersion]) {
		XMGPushGuideView*guideView=[XMGPushGuideView guideView];
		guideView.frame=window.bounds;
		[window addSubview:guideView];
		
		//版本保存到沙盒
		[[NSUserDefaults standardUserDefaults]setObject:currentVersion forKey:versionKey];
		[[NSUserDefaults standardUserDefaults] synchronize];
	}
}
@end
